# Empty list
SET(TINES_EXAMPLE_SOURCES "")
SET(TINES_EXAMPLE_DEVICE_SOURCES "")

# Append examples for checking functionality
LIST(APPEND TINES_EXAMPLE_SOURCES
  Tines_MachineParameters.cpp
  Tines_ComputeConditionNumber.cpp
  Tines_Gemv.cpp    
  Tines_Gemm.cpp
  Tines_Givens.cpp  
  Tines_Hessenberg.cpp
  Tines_InvertMatrix.cpp
  Tines_QR.cpp
  Tines_QR_WithColumnPivoting.cpp
  Tines_UTV.cpp
  Tines_SolveUTV.cpp
  Tines_SolveUTV_Simple.cpp  
  Tines_SolveLinearSystem.cpp
  Tines_Schur.cpp
  Tines_Schur_HostTPL.cpp  
  Tines_RightEigenvectorSchur.cpp
  Tines_RightEigenvector.cpp
  Tines_EigenvalueSchur.cpp
  Tines_SolveEigenvaluesNonSymmetricProblem.cpp
)

LIST(APPEND TINES_EXAMPLE_DEVICE_SOURCES
  Tines_FileInterface.cpp
  Tines_GemmDevice.cpp
  Tines_HessenbergDevice.cpp
  Tines_SchurDevice.cpp
  Tines_RightEigenvectorSchurDevice.cpp
  Tines_SolveEigenvaluesNonSymmetricProblemDevice.cpp
)

#
# Create examples for the above sources
#
FOREACH(TINES_EXAMPLE_SOURCE ${TINES_EXAMPLE_SOURCES} )
  STRING( REPLACE ".cpp" ".view.single.x" TINES_EXAMPLE_EXE ${TINES_EXAMPLE_SOURCE} )
  ADD_EXECUTABLE(${TINES_EXAMPLE_EXE} ${TINES_EXAMPLE_SOURCE})
  SET_TARGET_PROPERTIES(${TINES_EXAMPLE_EXE} PROPERTIES COMPILE_FLAGS "-DTINES_TEST_VIEW_INTERFACE -DTINES_TEST_SINGLE_PRECISION")
  TARGET_LINK_LIBRARIES(${TINES_EXAMPLE_EXE} ${TINES_LINK_LIBRARIES})
  INSTALL(TARGETS ${TINES_EXAMPLE_EXE}
          PERMISSIONS OWNER_EXECUTE OWNER_READ OWNER_WRITE
          DESTINATION "${CMAKE_INSTALL_PREFIX}/${TINES_INSTALL_EXAMPLE_PATH}")	  
ENDFOREACH()

FOREACH(TINES_EXAMPLE_SOURCE ${TINES_EXAMPLE_SOURCES} )
  STRING( REPLACE ".cpp" ".view.double.x" TINES_EXAMPLE_EXE ${TINES_EXAMPLE_SOURCE} )
  ADD_EXECUTABLE(${TINES_EXAMPLE_EXE} ${TINES_EXAMPLE_SOURCE})
  SET_TARGET_PROPERTIES(${TINES_EXAMPLE_EXE} PROPERTIES COMPILE_FLAGS "-DTINES_TEST_VIEW_INTERFACE -DTINES_TEST_DOUBLE_PRECISION")
  TARGET_LINK_LIBRARIES(${TINES_EXAMPLE_EXE} ${TINES_LINK_LIBRARIES})
  INSTALL(TARGETS ${TINES_EXAMPLE_EXE}
          PERMISSIONS OWNER_EXECUTE OWNER_READ OWNER_WRITE
          DESTINATION "${CMAKE_INSTALL_PREFIX}/${TINES_INSTALL_EXAMPLE_PATH}")	  
ENDFOREACH()

IF (((TINES_ENABLE_TPL_LAPACKE) AND (TINES_ENABLE_TPL_OPENBLAS)) OR (TINES_ENABLE_TPL_MKL))
  FOREACH(TINES_EXAMPLE_SOURCE ${TINES_EXAMPLE_SOURCES} )
    STRING( REPLACE ".cpp" ".ptr.single.x" TINES_EXAMPLE_EXE ${TINES_EXAMPLE_SOURCE} )
    ADD_EXECUTABLE(${TINES_EXAMPLE_EXE} ${TINES_EXAMPLE_SOURCE})
    SET_TARGET_PROPERTIES(${TINES_EXAMPLE_EXE} PROPERTIES COMPILE_FLAGS "-DTINES_TEST_TPL_POINTER_INTERFACE -DTINES_TEST_SINGLE_PRECISION")
    TARGET_LINK_LIBRARIES(${TINES_EXAMPLE_EXE} ${TINES_LINK_LIBRARIES})
    INSTALL(TARGETS ${TINES_EXAMPLE_EXE}
            PERMISSIONS OWNER_EXECUTE OWNER_READ OWNER_WRITE
            DESTINATION "${CMAKE_INSTALL_PREFIX}/${TINES_INSTALL_EXAMPLE_PATH}")
  ENDFOREACH()
  FOREACH(TINES_EXAMPLE_SOURCE ${TINES_EXAMPLE_SOURCES} )
    STRING( REPLACE ".cpp" ".ptr.double.x" TINES_EXAMPLE_EXE ${TINES_EXAMPLE_SOURCE} )
    ADD_EXECUTABLE(${TINES_EXAMPLE_EXE} ${TINES_EXAMPLE_SOURCE})
    SET_TARGET_PROPERTIES(${TINES_EXAMPLE_EXE} PROPERTIES COMPILE_FLAGS "-DTINES_TEST_TPL_POINTER_INTERFACE -DTINES_TEST_DOUBLE_PRECISION")
    TARGET_LINK_LIBRARIES(${TINES_EXAMPLE_EXE} ${TINES_LINK_LIBRARIES})
    INSTALL(TARGETS ${TINES_EXAMPLE_EXE}
            PERMISSIONS OWNER_EXECUTE OWNER_READ OWNER_WRITE
            DESTINATION "${CMAKE_INSTALL_PREFIX}/${TINES_INSTALL_EXAMPLE_PATH}")
  ENDFOREACH()
ENDIF()

FOREACH(TINES_EXAMPLE_SOURCE ${TINES_EXAMPLE_DEVICE_SOURCES} )
  STRING( REPLACE ".cpp" ".single.x" TINES_EXAMPLE_EXE ${TINES_EXAMPLE_SOURCE} )
  ADD_EXECUTABLE(${TINES_EXAMPLE_EXE} ${TINES_EXAMPLE_SOURCE})
  SET_TARGET_PROPERTIES(${TINES_EXAMPLE_EXE} PROPERTIES COMPILE_FLAGS "-DTINES_TEST_SINGLE_PRECISION")  
  TARGET_LINK_LIBRARIES(${TINES_EXAMPLE_EXE} ${TINES_LINK_LIBRARIES})
  INSTALL(TARGETS ${TINES_EXAMPLE_EXE}
          PERMISSIONS OWNER_EXECUTE OWNER_READ OWNER_WRITE
          DESTINATION "${CMAKE_INSTALL_PREFIX}/${TINES_INSTALL_EXAMPLE_PATH}")
ENDFOREACH()
FOREACH(TINES_EXAMPLE_SOURCE ${TINES_EXAMPLE_DEVICE_SOURCES} )
  STRING( REPLACE ".cpp" ".double.x" TINES_EXAMPLE_EXE ${TINES_EXAMPLE_SOURCE} )
  ADD_EXECUTABLE(${TINES_EXAMPLE_EXE} ${TINES_EXAMPLE_SOURCE})
  SET_TARGET_PROPERTIES(${TINES_EXAMPLE_EXE} PROPERTIES COMPILE_FLAGS "-DTINES_TEST_DOUBLE_PRECISION")  
  TARGET_LINK_LIBRARIES(${TINES_EXAMPLE_EXE} ${TINES_LINK_LIBRARIES})
  INSTALL(TARGETS ${TINES_EXAMPLE_EXE}
          PERMISSIONS OWNER_EXECUTE OWNER_READ OWNER_WRITE
          DESTINATION "${CMAKE_INSTALL_PREFIX}/${TINES_INSTALL_EXAMPLE_PATH}")
ENDFOREACH()
